using System;
using System.Threading.Tasks;
using Terra.Core.Common.Models.Pagination;
using Terra.Data.Entities.Logging;
using Terra.Data.Repository;

namespace Terra.Data.Repository.Logging;

/// <summary>
/// 登录日志仓储接口
/// </summary>
public interface ILoginLogRepository : IRepository<LoginLog, Guid>
{
    /// <summary>
    /// 分页查询登录日志
    /// </summary>
    /// <param name="userName">用户名(可选)</param>
    /// <param name="status">登录状态(可选)</param>
    /// <param name="startTime">开始时间(可选)</param>
    /// <param name="endTime">结束时间(可选)</param>
    /// <param name="pageIndex">页码</param>
    /// <param name="pageSize">每页大小</param>
    /// <returns>分页结果</returns>
    Task<PagedList<LoginLog>> GetPagedListAsync(
        string userName = null,
        bool? status = null,
        DateTime? startTime = null,
        DateTime? endTime = null,
        int pageIndex = 1,
        int pageSize = 10);

    /// <summary>
    /// 清理指定时间之前的日志
    /// </summary>
    /// <param name="beforeTime">清理该时间之前的日志</param>
    /// <returns>清理的记录数</returns>
    Task<int> CleanAsync(DateTime beforeTime);
}